/**
*@class Motion
*@brief ??? Manages the moves of the robot ???
*@author Elias Puttemans
*@date 04-2011
* 
* @section source Sources
* Receive code from IR, mousecc, ai
*
* @section working What does the code
* Manages the moves of the robot
*
* @section destination Destination
* Drivecontrol
*
*/

#ifndef MOTION_H
#define MOTION_H

#include <math.h>
#include <stdio.h>
#include "location.h"
#include "drivecontrol.h"

enum motionState {mStrait, stopped};

class Motion
{
public:
    Motion();
	//i have to get the initial location
	Motion(Location currLoc);
	~Motion();

	/**
	*@brief moveStrait
	*@param the location we want to go to
	*moveStrait accepts a Location and drives to it. Function returns after first rotation
	*/
	void moveStrait( Location targetLoc);

	/**
	*@brief rotate
	*@param rotates to given rotation, disregards coordinates
	*/
	void rotate( Location targetLoc);

	/**
	*@brief catchBall
	*@param targetLoc ball is situated around targetLoc.
	* function assumes we drive more or less strait into the ball
	* returns -1 if no ball found
	* returns immediately if ball was spotted and catching process is initiated
	*/
	int catchBall (Location targetLoc);

	/**
	*@brief kickBall
	*@param ball should be kicked in given angle, disregards coordinates
	*returns after rotation and kicking is done
	*/
	void kickBall (Location targetLoc);

	/**
	*@brief stop
	*stops whatever we are doing
	*/
	void stop();

	/**
	*@brief updateLocation
	*@param current Location
	*for the moment i assume i get periodical location updates this way, and then returns instantly
	*/
	void updateLocation(Location currLoc);

	float approachAngle(Location dest);
	bool arrived();
	/**
	 * determens the correction nessecary and updates the targetLoc_ to the new possition
	 */
	bool correction();

	//vars
	int normSpeed_;
	int deviX_, deviY_;
	float deviR_;
private:


	//Drivecontrol drivec;

	//private variables
    	Location targetLoc_;
    	Location currLoc_;

    	motionState state_;

    	Drivecontrol *drivec;
    	Log *log;
};

#endif
